const app = getApp()
import util from '../../../utils/util'
import {
  GetReleaseList
} from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isEmpty: false,
    lists: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let adminInfo = wx.getStorageSync('adminInfo')
    this.setData({
      adminInfo
    })

    this.getLists()
  },

  getLists() {
    let that = this;
    util.apiRequest(GetReleaseList, {
      id: that.data.adminInfo.id,
      vollege_id: app.globalData.vollege_id
    }, null).then(r => {
      console.log('管理员下发列表', r)

      var newList = that.data.lists.concat(r.data.data)

      if (r.data.data == '') {
        wx.showToast({
          title: '暂无更多',
          icon: 'none',
        })
      }

      that.setData({
        lists: newList
      })

      wx.hideLoading();

      if (newList.length == 0) {
        that.setData({
          isEmpty: true
        })
      } else {
        that.setData({
          isEmpty: false
        })
      }

    })
  },

  checkDetail(e) {
    let that = this;
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/grid/document_detail/document_detail?id=' + id,
    })
  },

  toIssueForm() {
    wx.navigateTo({
      url: '/pages/grid/admin_issue_form/admin_issue_form',
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})